﻿using System;
using System.Collections.Generic;
using System.Text;
using Watchdog.Bll.Factory;

namespace Watchdog.Bll.Base {

    public partial class ScheduleBase {

        #region [ Local variables ]
        internal Facade.Schedule intdata;
        #endregion

        #region [ Constructor(s) ]
        internal ScheduleBase () {
            intdata = new Watchdog.Facade.Schedule ();
        }
        internal ScheduleBase (Facade.Schedule schedule) : base () {
            intdata = schedule;
        }
        #endregion

        #region [ Field Properties ]
        public int Id {
            get { return intdata.Id; }
        }
        public virtual int Test {
            get { return intdata.Test; }
            set { intdata.Test = value; }
        }
        //public virtual bool Paused {
        //    get { return intdata.Paused; }
        //    set { intdata.Paused = value; }
        //}
        //public virtual DateTime DateStart {
        //    get { return intdata.DateStart; }
        //    set { intdata.DateStart = value; }
        //}
        //public virtual DateTime DateStop {
        //    get { return intdata.DateStop; }
        //    set { intdata.DateStop = value; }
        //}
        //public virtual string HourStart {
        //    get { return intdata.HourStart; }
        //    set { intdata.HourStart = value; }
        //}
        //public virtual string HourStop {
        //    get { return intdata.HourStop; }
        //    set { intdata.HourStop = value; }
        //}
        //public virtual Int16 RepeatType {
        //    get { return intdata.RepeatType; }
        //    set { intdata.RepeatType = value; }
        //}
        //public virtual Int16 RepeatInterval {
        //    get { return intdata.RepeatInterval; }
        //    set { intdata.RepeatInterval = value; }
        //}
        //public virtual int Days {
        //    get { return intdata.Days; }
        //    set { intdata.Days = value; }
        //}
        //public virtual int Weeks {
        //    get { return intdata.Weeks; }
        //    set { intdata.Weeks = value; }
        //}
        //public virtual int Months {
        //    get { return intdata.Months; }
        //    set { intdata.Months = value; }
        //}
        //public virtual DateTime NextRun {
        //    get { return intdata.NextRun; }
        //    set { intdata.NextRun = value; }
        //}
        //public virtual DateTime LastRun {
        //    get { return intdata.LastRun; }
        //    set { intdata.LastRun = value; }
        //}
        //public virtual DateTime Locked {
        //    get { return intdata.Locked; }
        //    set { intdata.Locked = value; }
        //}
        #endregion
		
        #region [ Data Methods ]
        public void Update () {
            if (Id == -1)
                ScheduleFactory.Insert ( this );
            else
                ScheduleFactory.Update ( this );
        }

        public void Delete () {
            ScheduleFactory.Delete ( this );
        }
        #endregion

		#region [ Many to many relations native type ]

		#endregion

		#region [ Add & Remove methods for many to many relations native type ]

		#endregion
		
        internal Facade.Schedule IntData {
            get { return intdata; }
            set { intdata = value; }
        }

        #region [ Equality ]
        public override int GetHashCode () {
            return Id;
        }
        public static bool operator == ( ScheduleBase lt1, ScheduleBase lt2 ) {
            if (System.Object.ReferenceEquals ( lt1, lt2 ))
                return true;

            if ((object)lt1 == null || (object)lt2 == null)
                return false;
            return lt1.Equals ( lt2 );
        }
        public static bool operator != ( ScheduleBase lt1, ScheduleBase lt2 ) {
            if (lt1 == null || lt2 == null)
                return false;
            return !(lt1 == lt2);
        }

        public override bool Equals ( object obj ) {
            if (!(obj is ScheduleBase))
                return false;
            return (this.CompareTo ( obj ) == 0);
        }

        private int CompareTo ( object obj ) {
            if (!(obj is ScheduleBase)) {
                throw new ArgumentException ( "A 'ScheduleBase' object is required for comparison." );
            }
            return this.Id.CompareTo ( ((ScheduleBase)obj).Id );
        }
        #endregion

	}
}
